#include <bits/stdc++.h>

using namespace std;

const int MAXN = 120*120+10010;

int f[MAXN],g[MAXN],n,v[110],c[110],mx,t;

int main (){
	scanf("%d %d",&n,&t);
	for(int i = 1;i <= n;i++) scanf("%d",&v[i]),mx = max(mx,v[i] * v[i]);
	mx += t;
	for(int i = 1;i <= n;i++) scanf("%d",&c[i]);
	memset(f,0x3f,sizeof(f));memset(g,0x3f,sizeof(g));
	f[0] = 0;g[0] = 0;
	for(int i = 1;i <= n;i++)
		for(int j = v[i];j <= mx;j++) g[j] = min(g[j],g[j-v[i]]+1);
	for(int i = 1;i <= n;i++){
		for(int k = 1;k <= c[i];k <<=1){
			c[i] -= k;
			for(int d = mx;d >= v[i] * k;d--)
				f[d] = min(f[d],f[d-v[i]*k]+k);
		}
		if(c[i]){
			for(int d = mx;d >= v[i] * c[i];d--)
				f[d] = min(f[d],f[d-v[i]*c[i]]+c[i]);
		}
	}
	int ans = 0x3f3f3f3f;
	for(int i = 0;i <= mx-t;i++) ans = min(ans,g[i] + f[i+t]);
	if(ans == 0x3f3f3f3f) ans = -1;
	printf("%d\n",ans);
}
